<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title><s:property value='%{getText("map_title")}' />
		</title>
		<link href="/SCMDB/style/main.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="/SCMDB/js/Super.js"></script>
		<script type="text/javascript" src="/SCMDB/js/jquery-1.4.2.js"></script>
		<s:include value="../commonPage/message.jsp" />
	</head>
	<body>
		<div class="main">
			<s:form action="uploadLabelIOAction!init.action" method="post" theme="simple">
			  <fieldset class="fieldSearch">
				<legend>考勤上传设置</legend>
				  <table border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td align="right" class="p_8">自动上传时间（单位：秒）：</td>
						<td><s:textfield cssClass="sInput" name="autoUploadTime"></s:textfield><input type="hidden" value="must-input;must-number"/></td>
						<td align="right" class="p_14" colspan="2">
						  <p class="pEdit">
						  	<s:if test='%{1==uploadStatus}'>
								<input type="button" class="bAdd" disabled="true"  value="上传" id="uploadButton" onclick="uploadStart()"></input>
								<input type="button" class="bAdd" value="停止" id="stopUploadButton" onclick="stopUploadStart()"></input>
						    </s:if>
						    <s:else>
						    	<input type="button" class="bAdd" value="上传" id="uploadButton" onclick="uploadStart()"></input>
								<input type="button" class="bAdd" disabled="true" value="停止" id="stopUploadButton" onclick="stopUploadStart()"></input>
						    </s:else>
						  </p>
						</td>
					</tr>
				  </table>
				</fieldset>
				<table  border="0" cellpadding="1" cellspacing="1" class="tableList">
					<thead>
						<tr>
							<th class="number">
								<s:property value='%{getText("area_th1")}' />
							</th>
							<th>
								自动上传时间（/秒）
							</th>
							<th>
								上传状态
							</th>
							<th>
								最后一次上传时间
							</th>
							<th>
								上传消息
							</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td class="number">
								1
							</td>
							<td>
								<div><s:property value="autoUploadTime"/></div>
							</td>
							<td>
								<div id="uploadSatusDiv">
									<s:if test='%{1==uploadStatus}'>
										上传正常
									</s:if>
									<s:else>
										上传停止
									</s:else>
								</div>
							</td>
							<td>
								<div id="lastUploadTimeDiv"><s:property value="lastUploadTime"/></div>
							</td>
							<td>
								<div id="messageUploadLabelIO"><s:property value="messageUploadLabelIO"/></div>
							</td>
						</tr>
					</tbody>
				</table>
			</s:form>
		</div>
	</body>
</html>
<script>
function refresh(){
	var parameter = {}
	var url = "/SCMDB/uploadLabelIOAction!getRealtimeConf.action";
	jQuery.post(url, parameter, setLastUploadTime);
	//window.setTimeout(refresh, 10 * 1000);
}
function setLastUploadTime(result){
	var data = eval("("+result+")");
	for (var j = 0; j < data.length; j++) {
		document.getElementById("lastUploadTimeDiv").innerText  = data[0].lastUploadTime;
	
		if ("1" == data[j].uploadStatus) {
			document.getElementById("uploadButton").disabled="true";
			document.getElementById("stopUploadButton").removeAttribute("disabled");
			document.getElementById("uploadSatusDiv").innerText="上传正常";
		} else{
			document.getElementById("uploadButton").removeAttribute("disabled");
			document.getElementById("stopUploadButton").disabled="true";
			document.getElementById("uploadSatusDiv").innerText="上传停止";
		}
	}
}
function uploadStart(){
	var autoUploadTime = document.getElementById("uploadLabelIOAction_autoUploadTime").value;
	if(""==autoUploadTime){
		Super.Popup(2,"警告","","自动上传时间不能为空!");
		return false;
	}
	var areaNum = "^[0-9]+$";
	var ra = new RegExp(areaNum);
	if (!ra.test(autoUploadTime)) {
		Super.Popup(2,"警告","","自动上传时间只能输入正整数!");
		return false;
	}
	var url = "/SCMDB/uploadLabelIOAction!uploadLabelIO.action?autoUploadTime="+autoUploadTime;
	window.location.href=url;
}
function stopUploadStart(){
	var url = "/SCMDB/uploadLabelIOAction!stopUploadLabelIO.action";
	window.location.href=url;
}
</script>